home *** CD-ROM | disk | FTP | other *** search
- Path: news.magi.com!newsadm
- From: mlefebvr@magi.com (Michel L.)
- Newsgroups: comp.lang.c
- Subject: double-->float... number changes
- Date: Wed, 17 Apr 1996 21:43:17 GMT
- Organization: Magi Data Consulting
- Message-ID: <4l3olr$85o@news.magi.com>
- NNTP-Posting-Host: magi04p65.magi.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- I have a number (that I pick up from Sybase), declared as a double,
- it's value is 123.4, I then want to store it in a float variable, but
- the number changes to 123.399994.
-
- float flt_number=0;
- double dbl_number=123.4;
- flt_number = dbl_number;
-
- flt_number is 123.399994.
-
- This messes up calculations later on in program.
- I tried converting the number to a string and using atof() to get a
- float number, but this function returns a double?!, and the subsequent
- conversion to a float produces the same error.
-
- Is there a way to get 123.4 when converting to a float number?
-
- Thanks in advance!
-
-